package com.drg.center.controller;

import com.drg.center.entity.param.SysRoleAddDTO;
import com.drg.center.entity.param.SysRoleEditDTO;
import com.drg.center.entity.param.SysRoleListDTO;
import com.drg.center.entity.result.SysRoleVO;
import com.guaike.core.entity.result.PageEntity;
import com.guaike.core.entity.result.Result;
import com.drg.center.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author: zhangxilin
 * @Date: 2024/5/22
 */

@RestController
@RequestMapping("/role")
@Api(tags = "系统-角色接口组")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;


    @PostMapping("/add")
    @ApiOperation(value = "添加")
    public Result<Boolean> add(@Valid @RequestBody SysRoleAddDTO param){
        return sysRoleService.add(param);
    }

    @PostMapping("/edit")
    @ApiOperation(value = "编辑")
    public Result<Boolean> edit(@Valid @RequestBody SysRoleEditDTO param){
        return sysRoleService.edit(param);
    }

    @GetMapping("/detail")
    @ApiOperation(value = "详情")
    public Result<SysRoleVO> detail(@ApiParam("ID") @RequestParam("id") Long id){
        return sysRoleService.detail(id);
    }

    @GetMapping("/findPage")
    @ApiOperation(value = "列表")
    public Result<PageEntity<SysRoleVO>> findPage(@Valid SysRoleListDTO param){
        return sysRoleService.findPage(param);
    }

    @GetMapping("/all")
    @ApiOperation(value = "所有角色")
    public Result<List<SysRoleVO>> all(){
        return sysRoleService.all();
    }

    @DeleteMapping("/delete")
    @ApiOperation(value = "删除")
    public Result<Boolean> delete(@ApiParam("ID") @RequestParam("id") Long id){
        return sysRoleService.delete(id);
    }

}
